

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-07-25
 * Time: 13:09
 */

class MyThread extends Thread{
    @Override
    public void run() {
        while(true){
            try {
                System.out.println("我是thread");
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class TestDemo {


    public static void main(String[] args) {

        Thread  t = new MyThread();

        t.start();//创建线程

        while(true){
            try {
                System.out.println("我是main");
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }


}
